import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index.vue'
// import store from '@/store'
import "reset-css"

// const originalPush = VueRouter.prototype.push;
// VueRouter.prototype.push = function (location) {
//   return originalPush.call(this, location).catch(err => { })
// };

Vue.use(VueRouter);
// 定义路由
const routes = [
  // 主页重定向，确保页面打开时能定向到主页
    {
      path: "/",
      redirect:"/Index"
    },
    // 跳转到的组件
    {
    // 路径
      path: '/Index',
    // 名称
      name: '首页',
    // 组件
      component: Index
    },
    {
        path: '/Detial',
        name: '详情',
        component: () => import('../views/detial.vue')
      },
      {
        path: '/Gift',
        name: '全部礼品',
        component: () => import('../views/gift.vue')
      },
      {
        path: '/UserCenter',
        name: '个人中心',
        component: () => import('../views/user.vue')
      },
      {
        path: '/MyList',
        name: '我的订单',
        component: () => import('../views/mylist.vue')
      },
      {
        path: '/Free',
        name: '专属福利',
        component: () => import('../views/free.vue')
      },
];
// 实例化VueRouter路由并将routes添加进去
const router = new VueRouter({
    routes
  });
  
// 抛出对象方便访问
  export default router;